package com.hardson.toolkit.util;

public class ArrayUtil {

    public static boolean isEmpty(final Object[] arr) {
        return arr == null || arr.length == 0;
    }

    public static boolean isEmpty(final byte[] arr) {
        return arr == null || arr.length == 0;
    }

    public static boolean isEmpty(final short[] arr) {
        return arr == null || arr.length == 0;
    }

    public static boolean isEmpty(final int[] arr) {
        return arr == null || arr.length == 0;
    }

    public static boolean isEmpty(final long[] arr) {
        return arr == null || arr.length == 0;
    }

    public static boolean isEmpty(final float[] arr) {
        return arr == null || arr.length == 0;
    }

    public static boolean isEmpty(final double[] arr) {
        return arr == null || arr.length == 0;
    }

    @SuppressWarnings("unchecked")
    public static <T> T[] of(T... t) {
        return t;
    }

    public static byte[] of(byte... arr) {
        return arr;
    }

    public static short[] of(short... arr) {
        return arr;
    }

    public static int[] of(int... arr) {
        return arr;
    }

    public static long[] of(long... arr) {
        return arr;
    }

    public static float[] of(float... arr) {
        return arr;
    }

    public static double[] of(double... arr) {
        return arr;
    }

    public static Object[] mearge(Object[] arr1, Object... arr2) {
        Object[] arr = new Object[arr1.length + arr2.length];
        int i = 0;
        for (Object obj : arr1) {
            arr[i++] = obj;
        }
        for (Object obj : arr2) {
            arr[i++] = obj;
        }
        return arr;
    }
}
